package a_o2odata_deal

import a_aa_amainpackage.a_o2odata_deal.config.FieldsConfig._
import org.apache.spark.sql.SQLContext
import org.apache.spark.{SparkConf, SparkContext}


/**
  * @ Auther: o2o-rd-0008
  * @ Date:   2019/11/27 15:48
  * @ Param:  ${PARAM}
  * @ Description: 
  */
object cate_main {
  def main(args: Array[String]): Unit = {
    val conf = new SparkConf()
    conf.setAppName(s"${this.getClass.getSimpleName}")
    conf.set("spark.debug.maxToStringFields", "500")
    //conf.setMaster("local[*]")
    conf.set("es.nodes", "192.168.1.157")
    conf.set("es.port", "9200")
    conf.set("cluster.name", "O2OElastic")
    conf.set("spark.serializer", "org.apache.spark.serializer.KryoSerializer")
    conf.set("spark.sql.caseSensitive", "true")
    val sc = new SparkContext(conf)
    val sqlContext = new SQLContext(sc)
    sc.setLogLevel("WARN")
    sc.hadoopConfiguration.set("fs.s3a.access.key", "GAO7EO9FWKPJ8WFCQDME")
    sc.hadoopConfiguration.set("fs.s3a.secret.key", "LZ0xaHBSYKHaJ9ECDbX9f7zin79UZkXfGoNapRPL")
    //sc.hadoopConfiguration.set("fs.s3a.endpoint", "https://obs.cn-north-1.myhuaweicloud.com")

    val sellpriceres = sqlContext.read.json(s"s3a://o2o-dataproces-group/panzonghao/2020/3/all_good")

    //val sellpriceres = sellandpricerestart(sqlContext)
    otherrestart(sqlContext, sellpriceres)

    /*val result = sqlContext.read.orc(s"s3a://o2o-dataproces-group/han_congcong/2019/12/tmall_brandresult_modify_v1")
      .selectExpr("good_id","priceText","sellCount","salesAmount")
    val source_data = sqlContext.read.json("s3a://o2o-dataproces-group/panzonghao/tmall/12/backups/")
      .selectExpr("good_id","priceText","sellCount","salesAmount")
    result.createOrReplaceTempView("result")
    source_data.createOrReplaceTempView("source_data")

    sqlContext.sql(
      s"""
         |select
         |t1.*,
         |t2.priceText as priceText2,
         |t2.sellCount as sellCount2,
         |t2.salesAmount as salesAmount2
         |from result t1
         |inner join
         |source_data t2
         |on t1.good_id=t2.good_id
         |where cast(t1.priceText as double)>cast(t2.priceText as double)
       """.stripMargin).show(1000,false)
*/

     //a_o2odata_deal.utils.handle_zhibo_zhubo.handle_zhubo_good(sqlContext)
     //a_o2odata_deal.utils.handle_zhibo_zhubo.handle_zhubo(sqlContext)
     //a_o2odata_deal.utils.handle_zhibo_v2.handle_zhibo(sqlContext)

    /*for (months <- 5 to 5){
      a_o2odata_deal.utils.handle_zhibo_v2_loop.handle_zhibo(sqlContext,s"${months}")
      //a_o2odata_deal.utils.handle_zhibo_zhubo_loop.handle_zhubo_good(sqlContext,s"${months}")
      //a_o2odata_deal.utils.handle_zhibo_zhubo_loop.handle_zhubo(sqlContext,s"${months}")
    }*/




    sc.stop()
  }
}
